package com.qidian.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author  戴着假发的程序员
 */
@Configuration
// 扫描所有的controller
@ComponentScan("com.qidian.controller")
// 添加SpringMVC相关配置
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 静态资源的映射
        registry.addResourceHandler("/**/*.html").addResourceLocations("/");
        registry.addResourceHandler("/**/*.css").addResourceLocations("/");
        registry.addResourceHandler("/**/*.js").addResourceLocations("/");
        registry.addResourceHandler("/**/*.png").addResourceLocations("/");
        registry.addResourceHandler("/**/*.jpg").addResourceLocations("/");
        registry.addResourceHandler("/lib/**/*.*").addResourceLocations("/lib/");
        registry.addResourceHandler("/**/*.json").addResourceLocations("/");
    }
}